﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace Fadd.Net
{
    /// <summary>
    /// Used to transport objects between two end points.
    /// </summary>
    /// <remarks>
    /// Uses <see cref="IObjectTransport{T}"/> for transportation, which should be reliable.
    /// </remarks>
    public interface IRemoteChannel
    {
        /// <summary>
        /// Register handler for an object
        /// </summary>
        /// <typeparam name="T">Type of object to receive.</typeparam>
        /// <param name="consumer">Implementation to invoke when object is received.</param>
        void Register<T>(IRemoteObjectConsumer<T> consumer);

        /// <summary>
        /// Send an object
        /// </summary>
        /// <param name="value">Object to send, must implement <see cref="ISerializable"/>.</param>
        void Send(object value);
    }

    /// <summary>
    /// Consumer of incoming objects.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IRemoteObjectConsumer<T>
    {
        void Consume(T value);
    }
}
